<?php



namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use GuzzleHttp\Client;

class WebServiceController extends Controller
{
    public function callWebService()
    {

        $client = new Client();
        $response = $client->request('GET', 'http://scm.zhongmei.com:9019/hnzmyy_webservice_4.3.32/services/OrderFBService?wsdl');


        $client = new Client([
            'base_uri' => 'http://scm.zhongmei.com:9019/hnzmyy_webservice_4.3.32/services/OrderFBService?wsdl', // WebService 的 URL
            'timeout'  => 2.0,
        ]);

        try {
            // 发送 SOAP 请求
            $response = $client->post('service.php', [
                'headers' => [
                    'Content-Type' => 'text/xml',
                ],
                'body' => '<?xml version="1.0" encoding="utf-8"?>
                              <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                                  <soap:Body>
                                      <MethodName xmlns="http://example.com/">
                                          <param1>value1</param1>
                                          <param2>value2</param2>
                                      </MethodName>
                                  </soap:Body>
                              </soap:Envelope>',
            ]);

            $statusCode = $response->getStatusCode();
            $body = (string) $response->getBody();

            return response()->json(['status' => $statusCode, 'response' => $body]);
        } catch (\Exception $e) {
            return response()->json(['error' => $e->getMessage()], 500);
        }
    }
}

